
;(function(window,undefined){
 function init(el){
    let els = document.querySelectorAll(el)
    let arr = []
    arr.push.apply(this,els)
    }
let jQuery = function(el){
     return new init(el)
    }
jQuery.extend = function(object){
    for(let key in object){
        init.prototype[key]=object[key]
    }
 }
 init.prototype={
    css(cssAttr,cssVal){
            for(let i = 0;i<this.length;i++){
            this[i].style[cssAttr] = cssVal
        }
            console.log(this);
            return this
    }
 }

window.jQuery = window.$= jQuery
})(window)

let jqObj = jQuery('div')
jqObj.css('color','blue').css('line-height','100px')

jQuery.extend({
    bg:function(color){
        for(let i=0;i<this.length;i++){
        this[i].style.background = color 
        }
    },
    fn:function(){
        let sum = 0
        for(let i = 0;i<this.length;i++){
        sum+=parseInt(this[i].innerText)
            }
            return sum
        }
})
jqObj.bg('yellow')
console.log(jqObj.fn());

